package com.xiaoxiao.ssos.controller;

import com.xiaoxiao.ssos.base.model.DateResult;
import com.xiaoxiao.ssos.service.impl.FlowableServicelmpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/test")
public class TestController {


    @Autowired
    private FlowableServicelmpl flowableServicelmpl;
    @GetMapping("/add")
    public String add(String userId){
       return flowableServicelmpl.addTask(userId,"plan","test");
    }
    @GetMapping("/state")
    @ApiOperation("状态")
    public DateResult state(String id ){
        return DateResult.ok(flowableServicelmpl.state(id));
    }

    @GetMapping("/info")
    @ApiOperation("查看我要的审批")
    public DateResult info(String userId,String role){
        return DateResult.ok(flowableServicelmpl.applyInfo(userId,role));
    }

    @GetMapping("/histoic")
    @ApiOperation("流转历史")
    public DateResult histoic(String procInsId){
        return DateResult.ok(flowableServicelmpl.historic(procInsId));
    }

    @GetMapping("/claim")
    @ApiOperation("签收任务")
    public DateResult claim(String taskId,String role,String userId){
        flowableServicelmpl.claim(taskId,userId,role);
    return DateResult.ok();
    }


    @GetMapping("/sendinfo")
    @ApiOperation("查看我的提交的审批" )
    public DateResult send(String userId){
        return DateResult.ok(flowableServicelmpl.info(userId));
    }


    @GetMapping("/apply")
    public DateResult approval(String taskId,String procInsId,String userId,String var,String message) {
        flowableServicelmpl.approval(taskId,procInsId,userId,var,message);
        return DateResult.ok();
    }
}
